<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'资源添加', styles:'bootstrap,font-awesome,animate,style,dtvalidate,layer,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
    </style>
    <%}%>
</head>
<body>
<!-- START 内容部分 -->
<div class="container" >
    <form class="form-horizontal" id="info-form" method="post" autocomplete="off" style="margin: auto">
        <input type="hidden" name="id"  value="${despatch.id}">
        <input type="hidden" name="createSkuId"  value="${despatch.createSkuId}">
        <input type="hidden" name="createId"  value="${despatch.createId}">
        <input type="hidden" name="createPeriod"  value="${despatch.createPeriod}">
        <input type="hidden" name="createCustomRate"  value="${despatch.createCustomRate}">
        <input type="hidden" name="erpProducePrice"  value="${despatch.erpProducePrice}">
        <input type="hidden" name="despatchPort"  value="${despatchPlan.despatchPort}">
        <input type="hidden" name="despatchDest"  value="${despatchPlan.despatchDest}">
        <input type="hidden" name="despatchStore"  value="${despatchPlan.despatchStore}">
        <div class="form-group">
            <label class="control-label col-sm-2">数量</label>
            <div class="col-sm-6">
                <input type="text" id="createNumber" name="createNumber" value="${despatch.createNumber}" class="form-control">
                <input type="hidden" id="skuNumber" name="skuNumber" value="${despatch.createNumber}">
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-sm-2">备注</label>
            <div class="col-sm-6">
                <input type="text" id="createRemark" name="createRemark" value="${despatch.createRemark}" class="form-control">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- END 内容部分 -->

<!-- START 公共脚本 -->
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn,laydate,layer,chosen,chosen-demo'}){}%>
<!-- END 公共脚本 -->
<script>
    var cvalidator;
    $(function(){

        //初始化验证器
        cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
        //提交表单
        $('.save-btn').on('click',function(){
            var skuNumber=$("#skuNumber").val();
            var createNumber=$("#createNumber").val();
            if(parseInt(createNumber)>parseInt(skuNumber)){
                parent.layer.msg('不能超过当前分配数量！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }else if(parseInt(createNumber) != parseInt(skuNumber) && $("#createRemark").val()==''){
                parent.layer.msg('数量不一致,请填写备注！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
                return;
            }
            var index = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            //数据提交
            $.post('/sea/physical/despatch/change.do',$('#info-form').serialize(),function(data){
                if( data.ok ){
                    parent.layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']}, function(){
                        parent.$("#detailTable").bootstrapTable('refresh');
                        parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
                        layer.close(index);
                    });
                }else{
                    parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }
            });
        });
        //返回
        $('.return-btn').on('click',function(){
            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
        });
    });
</script>
</body>
</html>